<template>
	<view id="content">
		<view style="display: flex;justify-content: center; margin-top: 10rpx;">
			<view style="width: 700rpx;height: 400rpx;background-color: white;font-size: 28rpx;margin-top:10rpx;">
				<textarea v-model="fkInfo" maxlength=1000 style="padding-left: 25rpx;padding-top:60rpx;width: 660rpx;font-size: 32rpx;"
					placeholder="这一刻的想法 ... " placeholder-style="color:#d9d9d9"></textarea>
			</view>
		</view>
		
		<view class="img_area">
			<view v-show="img01Active" class="upload_img" @click="img01Click">
				<image :src="img01url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img02Active" class="upload_img" @click="img02Click">
				<image :src="img02url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img03Active" class="upload_img" @click="img03Click">
				<image :src="img03url" style="width: 100%;height: 100%;"></image>
			</view>
		</view>
		<view class="img_area">
			<view v-show="img04Active" class="upload_img" @click="img04Click">
				<image :src="img04url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img05Active" class="upload_img" @click="img05Click">
				<image :src="img05url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img06Active" class="upload_img" @click="img06Click">
				<image :src="img06url" style="width: 100%;height: 100%;"></image>
			</view>
		</view>
		<view class="img_area">
			<view v-show="img07Active" class="upload_img" @click="img07Click">
				<image :src="img07url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img08Active" class="upload_img" @click="img08Click">
				<image :src="img08url" style="width: 100%;height: 100%;"></image>
			</view>
			<view v-show="img09Active" class="upload_img" @click="img09Click">
				<image :src="img09url" style="width: 100%;height: 100%;"></image>
			</view>
		</view>

		<!-- <view @click="myLocation" style="display: flex;justify-content: center;margin-top: 100rpx;">
			所在位置
		</view>
		 -->

		<view class="submit" @click="fabiaoInfo">
			<view>发表</view>
		</view>
		
		<!-- 弹窗层 开始 -->
		<view class="overlay" v-if="showOverlay" @touchmove.stop.prevent="">
		  <view class="laybg">
			  <view  class="laybg_img">
				   <image src="../../static/daishenhe.png" style="width: 100%;height: 100%;"></image>
			  </view>
		  </view>
		  <view class="laytxt">待审核</view>
		  <view class="laytxt_dian">...</view>
		</view>
		<!-- 弹窗层 开始 -->
		
	</view>

</template>

<script>
	import config from '../../utils/config.js'
	import request from '../../utils/request.js'
	import {
		checkLogin
	} from '../../utils/common.js'

	export default {
		data() {
			return {
				tips: '',
				fkInfo: '',
				showOverlay: false,
				upServer: config.apiUrl,
				imgPrefx: config.imgPrefx,
				img01Active: true,
				img01url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img02Active: false,
				img02url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img03Active: false,
				img03url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img04Active: false,
				img04url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img05Active: false,
				img05url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img06Active: false,
				img06url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img07Active: false,
				img07url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img08Active: false,
				img08url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				img09Active: false,
				img09url: config.imgPrefx + "/zhujinhui/minis/shizi.png",
				pics:[]
			}
		},
		created() {
			//this.queryList()
		},
		onShow() {

		},
		methods: {
			fabiaoInfo() { // 发布朋友圈
			  let _this = this;
			  if ('' == _this.fkInfo) {
			    uni.showToast({
			      title: '内容不能为空',
			      icon: 'error',
			      duration: 1000
			    });
			    return;
			  }
			  request({
			    url: '/miniPyq/v1/add',
			    method: "POST",
			    data: {
			      txt: _this.fkInfo,
				  pics: _this.pics
			    }
			  }).then((res) => {
				if(res.code == 200 ){
					// uni.showToast({
					//   title: '内容审核中',
					//   icon: 'success',
					//   duration: 1000
					// });
					_this.showOverlay = ! _this.showOverlay
					setTimeout(function () {
					            uni.switchTab({
					              url: '/pages/wuliao/wuliao'
					            })
					}, 3000)
					
				}
			  })
			},
			img01Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								console.info("2222",_this.imgPrefx + aa.msg)
								if (aa.code == 200) {
									_this.img01url = _this.imgPrefx + aa.msg
									_this.img02Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img02Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img02url = _this.imgPrefx + aa.msg
									_this.img03Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img03Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img03url = _this.imgPrefx + aa.msg
									_this.img04Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img04Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img04url = _this.imgPrefx + aa.msg
									_this.img05Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img05Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img05url = _this.imgPrefx + aa.msg
									_this.img06Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img06Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img06url = _this.imgPrefx + aa.msg
									_this.img07Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img07Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img07url = _this.imgPrefx + aa.msg
									_this.img08Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img08Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img08url = _this.imgPrefx + aa.msg
									_this.img09Active = true;
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			img09Click() {
				var _this = this;
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						// 以响应的结果为主，进行页面回填
						//_this.img01url = res.tempFilePaths[0];
						//_this.img02Active = true;
						uni.uploadFile({
							url: _this.upServer + "/minio/upload", // 你的上传地址
							filePath: res.tempFilePaths[0],
							name: 'file', // 这里根据后端需要的字段来定义
							formData: {
								'user': 'test' // 其他要传的参数可以在这里添加
							},
							success: uploadFileRes => {
								var aa = JSON.parse(uploadFileRes.data);
								if (aa.code == 200) {
									_this.img09url = _this.imgPrefx + aa.msg
									_this.pics.push(aa.msg)
								}
							},
							fail: uploadFileError => {
								uni.showToast({
								  title: '图片上传失败',
								  icon: 'error',
								  duration: 1000
								});
							}
						});
					}
				});
			},
			myLocation() {
				uni.getLocation({
					success: function(res) {
						const latitude = res.latitude; // 纬度
						const longitude = res.longitude; // 经度
						console.log('当前位置的坐标：', latitude, longitude);
					},
					fail: function(res) {
						console.log('获取位置失败：', res);
					}
				});
			},
			toggleOverlay() {
			  var _this = this;
			  const token = uni.getStorageSync('token');
			  if (!token) {
			    _this.showOverlay = !_this.showOverlay;
			    return;
			  }
			  uni.navigateTo({
			    url: '/pages/jinengpx/jinengpx'
			  })
			},
			closed() {
			  this.showOverlay = !this.showOverlay;
			}
		}
	}
</script>

<style>
	page {
		// 整个页面白色背景实现方式1
		background-color: white;
	}

	.img_area {
		display: flex;
		justify-content: space-start;
		margin-top: 28rpx;
	}

	.upload_img {
		width: 210rpx;
		height: 210rpx;
		margin-left: 28rpx;
	}

	.submit {
		background-image: linear-gradient(to right, #fdd706, #fdb932);
		position: fixed;
		z-index: 22;
		top: 10rpx;
		right: 20rpx;
		font-size: 30rpx;
		width: 120rpx;
		height: 65rpx;
		border-radius: 56rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	/**自定义弹窗**/
	/**遮罩层底层背景图**/
	.overlay {
	  position: fixed;
	  top: 0;
	  left: 0;
	  right: 0;
	  bottom: 0;
	  background-color: rgba(0, 0, 0, 0.5); // 半透明遮罩层颜色
	  z-index: 91;
	}
	
	.laybg {
	  position: fixed;
	  top: 300rpx;
	  right: 150rpx;
	  z-index: 92;
	  height: 540rpx;
	  width: 480rpx;
	  border-radius: 50rpx;
	  background-color: white;
	}
	
	.laybg_img {
	  position: fixed;
	  top: 450rpx;
	  right: 300rpx;
	  z-index: 94;
	  width: 170rpx;
	  height: 170rpx;
	}
	
	.laytxt {
	  position: fixed;
	  top: 650rpx;
	  right: 83rpx;
	  z-index: 93;
	  width: 360rpx;
	  font-weight: 400;
	  font-size: 36rpx;
	}
	
	.laytxt_dian{
		position: fixed;
		top: 676rpx;
		right: 42rpx;
		z-index: 93;
		width: 360rpx;
		font-weight: 400;
		font-size: 36rpx;
	}
</style> -->